<?php


class GeneralModel extends AppModel {

// save record in all languages on create
function save($data = null, $validate = true, $fieldList = array()) {
	$creating = empty($this->id) && (!isset($this->data[$this->name][$this->primaryKey]) || empty($this->data[$this->name][$this->primaryKey]))
		 && (!isset($data[$this->name][$this->primaryKey]) || empty($data[$this->name][$this->primaryKey]));
	if ($creating && $this->Behaviors->attached('Translate')) {
		$this->locale = Configure::read('Config.language');
		$resultdata = parent::save($data, $validate, $fieldList);
		if ((bool)$resultdata) {
			// fieldList
			$fieldList = $this->Behaviors->Translate->settings[$this->name];
			$fieldList[] = $this->primaryKey;
			$resultdata[$this->name] = array_intersect_key($resultdata[$this->name], array_flip($fieldList));
			$resultdata[$this->name][$this->primaryKey] = $this->id;
			//
			$languages = Configure::read('Project.languages');
			foreach ($languages as $language_name => $language_description) {
				if ($language_name !== Configure::read('Config.language')) {
					$this->locale = $language_name;
					parent::save($resultdata, $validate, $fieldList);
				}
			}
		}
		$this->locale = Configure::read('Config.language');
		return $resultdata;
	} else {
		return parent::save($data, $validate, $fieldList);
	}
}

}


?>